package com.bluetooth.demo.utils;

import com.bluetooth.demo.model.UploadData;
import com.zhy.http.okhttp.OkHttpUtils;
import com.zhy.http.okhttp.callback.Callback;

/**
 * 上传接口地址
 */

public class HttpUtils {

    //private static String IP = "192.168.43.65";
    private static String IP = "47.114.187.60";
  //private static String IP = "192.168.1.106";

    private static String BASE_URL = "http://" + IP + ":8080";

    private static String PROJECT = "/WebService";

    private static final String UPLOAD_URL = BASE_URL + PROJECT + "/upload/upload.action";//上传

    private static final String LOGIN_URL = BASE_URL + PROJECT + "/login/login.action";//登录

    public static void upload(UploadData data, Callback callback) {

        OkHttpUtils
                .get()
                .url(UPLOAD_URL)
                .addParams("heartrate", String.valueOf(data.getHeartrate()))
                .addParams("walkstep", String.valueOf(data.getWalkstep()))
                .addParams("calorie", String.valueOf(data.getCalorie()))
                .addParams("eid", String.valueOf(data.getEid()))
                .addParams("date", String.valueOf(data.getDate()))
                .build()
                .execute(callback);

    }

    public static void login(String username, String password, Callback callback) {

        OkHttpUtils
                .get()
                .url(LOGIN_URL)
                .addParams("username", username)
                .addParams("password", password)
                .build()
                .execute(callback);

    }
}
